#include "PrecompiledHeader_FileSysMgr.h"
#include "XMLParser.h"

/*--------------------------------------------------------------------------*/

XMLParser::XMLParser()
{
	FileSys::RegisterParser(this, ".xml");
}

/*--------------------------------------------------------------------------*/

XMLParser::~XMLParser()
{
	FileSys::UnregisterParser(this);
}

/*--------------------------------------------------------------------------*/

void* XMLParser::Load( FileDesc* desc )
{
	XMLFile* file = new XMLFile(desc->GetFullname());

	bool result = file->m_xmlDocument.load_file(desc->GetPath().c_str());

	if (!result)
	{
		AssertLogC(!result, "Error parsing %s!", desc->GetPath().c_str());

		delete file;
		return NULL;
	}
	else
	{
		return file;
	}
}

/*--------------------------------------------------------------------------*/

void XMLParser::Unload( void* file )
{
	XMLFile* xmlfile = (XMLFile*) file;

	if (xmlfile)
	{
		//xmlfile->m_xmlDocument.destroy();
	}
}

/*--------------------------------------------------------------------------*/